<?php

namespace App\Models\Oauth;

use Illuminate\Support\Facades\DB;
use App\Models\Model;

class UserProfileModel extends Model
{

    const TABLENAME = 'tw_base_user_profile';

    /**
     * 初始化并返回数据库请求构建器
     *
     * @return Illuminate\Support\Facades\DB::table(TABLENAME)
     */
    public static function dbTable()
    {
        // return self::dbConnectionClub()->table(self::TABLE_NAME);
        return DB::table(self::TABLENAME);
    }

    /**
     * 添加一个用户的扩展信息
     */
    public static function addUserProfile($data = array())
    {
        if (self::dbTable()->insertGetId($data)) {
            return true;
        }
        return false;
    }

    public static function getUserProfile($where)
    {
        return self::dbTable()->select()->where($where)->first();
    }

    public static function updateUserProfile($uid,$data)
    {
        $where ['user_id'] = $uid;
        return self::dbTable()->where($where)->update($data);
    }
}

?>